#ifndef __character_obj_h__
#define __character_obj_h__

#include "character_base.h"

class tplayer;
class character_obj;

class objaction
{
protected:
	friend class objtimercont;
	character_obj *owner;
	long long t;
public:
	long long gett(){return t;}
	virtual void setowner(character_obj *o)
	{
		owner=o;
	}
	objaction():t(0){};
	virtual ~objaction(){};
	virtual void operator()(character_obj *o, tplayer *p)=0;
	virtual void timer(){};
};

class objtimercont
{
	long long t;
public:
	objaction *a;
	objtimercont(objaction *p):a(p),t(p->t){};
	objtimercont(const objtimercont &b):a(b.a),t(b.t){};
	objtimercont& operator=(const objtimercont &b)
	{
		a=b.a;
		t=b.t;
		return *this;
	}

	bool operator==(const objtimercont &b) const
	{
		return t==b.t;
	}
	bool operator<(const objtimercont &b) const
	{
		return t>b.t;
	}
};

class spawner;
class character_obj:public character_base
{
	friend class spawner;
	friend class flarisdroom;
	friend class objpsywall;
	void setmodeltype(int a)
	{
		modeltype=a;
	}
	std::list<character_obj*>::iterator gridcellremover;
	void removethis();
	objaction *oa;
	spawner *os;
	int tag;
public:
	std::list<character_obj*>::iterator& ggcr()
	{
		return gridcellremover;
	}
	void sgcr(const std::list<character_obj*>::iterator &a)
	{
		gridcellremover=a;
	}
	character_obj(int t, cluster *c, int m, float x1, float y1, float z1, int d, int s, objaction *oa1=0, spawner *os=0);
	virtual ~character_obj()
	{
		removethis();
	}
	void action(tplayer *p)
	{
		if(oa!=0)(*oa)(this, p);
	}
};

#endif
